<?php
/* 	These code was generated using phpCIGen v 2.a (21/05/2012)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com,
	#CV. Trust Solution, jl. Saronojiwo 2/19 Surabaya, http://www.ts.co.id

	+ Module  		: m_vendor View
	+ Description	: For record view
	+ Filename 		: v_m_vendor.php
 	+ creator  		: 
 	+ Created on 24/Jul/2012 11:40:14

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style type="text/css">
        p { width:650px; }
		.search-item {
			font:normal 11px tahoma, arial, helvetica, sans-serif;
			padding:3px 10px 3px 10px;
			border:1px solid #fff;
			border-bottom:1px solid #eeeeee;
			white-space:normal;
			color:#555;
		}
		.search-item h3 {
			display:block;
			font:inherit;
			font-weight:bold;
			color:#222;
		}

		.search-item h3 span {
			float: right;
			font-weight:normal;
			margin:0 0 5px 5px;
			width:100px;
			display:block;
			clear:none;
		}
    </style>
<script>
/* declare function */
var m_vendor_DataStore;
var m_vendor_ColumnModel;
var m_vendor_ListEditorGrid;
var m_vendor_saveForm;
var m_vendor_SelectedRow;
var m_vendor_ContextMenu;
/* decalare KONSTANSTA */
var FAILED_SAVE="Data gagal disimpan";
var FAILED_CONNECTION="Koneksi database server gagal, hubungi Administrator";
var FAILED_VALID_FORM="Data input belum sempurna";
var FAILED_DELETE_SELECTED="Tidak ada data yang terpilih untuk dihapus";
var FAILED_UPDATE_SELECTED="Tidak ada data yang terpilih untuk diupdate";
var FAILED_DELETE="Data gagal dihapus";
var FAILED_EXCEL="Data gagal diexport ke Excel";
var FAILED_PRINT="Data gagal dicetak";
var FAILED_PERMISSION="Anda tidak mempunyai akses untuk aksi ini";
var CONFIRM_DELETE="Apakah Anda yakin menghapus rekod ini?";
var CONFIRM_MULTI_DELETE="Apakah Anda yakin menghapus rekod-rekod ini?";
var SUCCESS_SAVE="Data sukses disimpan";
var TITLE_LIST="Daftar Data";
var TITLE_FORM="Form Input/Update";
var TITLE_FORM_SEARCH="Pencarian Lanjut";
var BTN_SAVE="Simpan";
var BTN_SEARCH="Cari";
var BTN_CANCEL="Batal";
var BTN_ADD_TITLE="Tambah";
var BTN_EDIT_TITLE="Ubah";
var BTN_DELETE_TITLE="Hapus";
var BTN_SEARCH_TITLE="Pencarian";
var BTN_PRINT_TITLE="Cetak";
var BTN_EXCEL_TITLE="Export Excel";
var BTN_REFRESH_TITLE="Refresh";
var BTN_ADD_TOOLTIP="Tambah Data Baru";
var BTN_EDIT_TOOLTIP="Ubah Data";
var BTN_DELETE_TOOLTIP="Hapus Data";
var BTN_SEARCH_TOOLTIP="Pencarian Data Lanjut";
var BTN_SIMPLE_SEARCH_TOOLTIP="Pencarian Sederhana";
var BTN_PRINT_TOOLTIP="Cetak Data (html)";
var BTN_EXCEL_TOOLTIP="Export ke bentuk Excel";
var BTN_REFERSH_TOOLTIP="Refresh Data";
var INFO_REQUIRED="Wajib diisi";
var PERMISSION="RCUD";
//declare konstant
var post2db = 'CREATE';
var msg = 'created';
var pageS=15;

/* declare variable here for Field*/
var vendor_idField;
var vendor_kodeField;
var vendor_nameField;
var vendor_typeField;
var vendor_addressField;
var vendor_phoneField;
var vendor_faxField;
var vendor_emailField;
var vendor_cpField;
var vendor_dirField;
var vendor_dirposField;
var vendor_rekField;
var vendor_bankField;
var vendor_bankownerField;
var vendor_certField;
var vendor_npwpField;
var vendor_certdateField;
var vendor_activeField;
var vendor_created_dateField;
var vendor_created_byField;
var vendor_updated_dateField;
var vendor_updated_byField;
var vendor_updated_countField;
var m_div_idField;
/* For search form */
var vendor_idSearchField;
var vendor_nameSearchField;
var vendor_typeSearchField;
var vendor_addressSearchField;
var vendor_phoneSearchField;
var vendor_faxSearchField;
var vendor_emailSearchField;
var vendor_cpSearchField;
var vendor_dirSearchField;
var vendor_dirposSearchField;
var vendor_rekSearchField;
var vendor_bankSearchField;
var vendor_bankownerSearchField;
var vendor_certSearchField;
var vendor_certdateSearchField;
var vendor_activeSearchField;
var vendor_created_dateSearchField;
var vendor_created_bySearchField;
var vendor_updated_dateSearchField;
var vendor_updated_bySearchField;
var vendor_updated_countSearchField;
var m_div_idSearchField;
var m_vendor_ListEditorGrid;
/* on ready fuction */
Ext.onReady(function(){
  	Ext.QuickTips.init();	/* Initiate quick tips icon */

  	/* Function for Saving inLine Editing */
	function m_vendor_inline_update(oGrid_event){

	var patt=new RegExp("U");
	if(patt.test(PERMISSION)==false){

		Ext.MessageBox.show({
		   title: 'Warning',
		   msg: FAILED_PERMISSION,
		   buttons: Ext.MessageBox.OK,
		   animEl: 'security',
		   icon: Ext.MessageBox.WARNING
		});

	}else{

		var vendor_id_update_pk="";
		var vendor_kode_update=null;
		var vendor_name_update=null;
		var vendor_type_update=null;
		var vendor_address_update=null;
		var vendor_phone_update=null;
		var vendor_fax_update=null;
		var vendor_email_update=null;
		var vendor_cp_update=null;
		var vendor_dir_update=null;
		var vendor_dirpos_update=null;
		var vendor_rek_update=null;
		var vendor_bank_update=null;
		var vendor_bankowner_update=null;
		var vendor_cert_update=null;
		var vendor_npwp_update=null;
		var vendor_certdate_update_date="";
		var vendor_active_update=null;
		var m_div_id_update=null;

		vendor_id_update_pk = oGrid_event.record.data.vendor_id;
		if(oGrid_event.record.data.vendor_kode!== null){vendor_kode_update = oGrid_event.record.data.vendor_kode;}
		if(oGrid_event.record.data.vendor_name!== null){vendor_name_update = oGrid_event.record.data.vendor_name;}
		if(oGrid_event.record.data.vendor_type!== null){vendor_type_update = oGrid_event.record.data.vendor_type;}
		if(oGrid_event.record.data.vendor_address!== null){vendor_address_update = oGrid_event.record.data.vendor_address;}
		if(oGrid_event.record.data.vendor_phone!== null){vendor_phone_update = oGrid_event.record.data.vendor_phone;}
		if(oGrid_event.record.data.vendor_fax!== null){vendor_fax_update = oGrid_event.record.data.vendor_fax;}
		if(oGrid_event.record.data.vendor_email!== null){vendor_email_update = oGrid_event.record.data.vendor_email;}
		if(oGrid_event.record.data.vendor_cp!== null){vendor_cp_update = oGrid_event.record.data.vendor_cp;}
		if(oGrid_event.record.data.vendor_dir!== null){vendor_dir_update = oGrid_event.record.data.vendor_dir;}
		if(oGrid_event.record.data.vendor_dirpos!== null){vendor_dirpos_update = oGrid_event.record.data.vendor_dirpos;}
		if(oGrid_event.record.data.vendor_rek!== null){vendor_rek_update = oGrid_event.record.data.vendor_rek;}
		if(oGrid_event.record.data.vendor_bank!== null){vendor_bank_update = oGrid_event.record.data.vendor_bank;}
		if(oGrid_event.record.data.vendor_bankowner!== null){vendor_bankowner_update = oGrid_event.record.data.vendor_bankowner;}
		if(oGrid_event.record.data.vendor_cert!== null){vendor_cert_update = oGrid_event.record.data.vendor_cert;}
		if(oGrid_event.record.data.vendor_npwp!== null){vendor_npwp_update = oGrid_event.record.data.vendor_npwp;}
	 	if(oGrid_event.record.data.vendor_certdate!== ""){vendor_certdate_update_date =oGrid_event.record.data.vendor_certdate.format('Y-m-d');}
		if(oGrid_event.record.data.vendor_active!== null){vendor_active_update = oGrid_event.record.data.vendor_active;}
	 	/* if(oGrid_event.record.data.vendor_created_date!== ""){vendor_created_date_update_date =oGrid_event.record.data.vendor_created_date.format('Y-m-d');}
		if(oGrid_event.record.data.vendor_created_by!== null){vendor_created_by_update = oGrid_event.record.data.vendor_created_by;}
	 	if(oGrid_event.record.data.vendor_updated_date!== ""){vendor_updated_date_update_date =oGrid_event.record.data.vendor_updated_date.format('Y-m-d');}
		if(oGrid_event.record.data.vendor_updated_by!== null){vendor_updated_by_update = oGrid_event.record.data.vendor_updated_by;}
		if(oGrid_event.record.data.vendor_updated_count!== null){vendor_updated_count_update = oGrid_event.record.data.vendor_updated_count;}
		 */if(oGrid_event.record.data.m_div_id!== null){m_div_id_update = oGrid_event.record.data.m_div_id;}

		Ext.Ajax.request({
			waitMsg: 'Please wait...',
			url: 'index.php?c=c_m_vendor&m=get_action',
			params: {
				vendor_id	: vendor_id_update_pk,
				vendor_kode	:vendor_kode_update,
				vendor_name	:vendor_name_update,
				vendor_type	:vendor_type_update,
				vendor_address	:vendor_address_update,
				vendor_phone	:vendor_phone_update,
				vendor_fax	:vendor_fax_update,
				vendor_email	:vendor_email_update,
				vendor_cp	:vendor_cp_update,
				vendor_dir	:vendor_dir_update,
				vendor_dirpos	:vendor_dirpos_update,
				vendor_rek	:vendor_rek_update,
				vendor_bank	:vendor_bank_update,
				vendor_bankowner	:vendor_bankowner_update,
				vendor_cert	:vendor_cert_update,
				vendor_npwp	:vendor_npwp_update,
				vendor_certdate	: vendor_certdate_update_date,
				vendor_active	:vendor_active_update,
				/* vendor_created_date	: vendor_created_date_update_date,
				vendor_created_by	:vendor_created_by_update,
				vendor_updated_date	: vendor_updated_date_update_date,
				vendor_updated_by	:vendor_updated_by_update,
				vendor_updated_count	:vendor_updated_count_update, */
				m_div_id	:m_div_id_update,
				task: "UPDATE"
			},
			success: function(response){
				var result=eval(response.responseText);
				switch(result){
					case 1:
						m_vendor_DataStore.commitChanges();
						m_vendor_DataStore.reload();
						break;
					default:
						Ext.MessageBox.show({
						   title: 'Warning',
						   msg: FAILED_SAVE,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'save',
						   icon: Ext.MessageBox.WARNING
						});
						break;
				}
			},
			failure: function(response){
				Ext.MessageBox.show({
				   title: 'Error',
				   msg: FAILED_CONNECTION,
				   buttons: Ext.MessageBox.OK,
				   animEl: 'database',
				   icon: Ext.MessageBox.ERROR
				});
			}
		});

		}
	}
  	/* End of Function */

  	/* Function for add and edit data form, open window form */
	function m_vendor_save(){

		var patt=new RegExp("U");
		var patt2=new RegExp("C");
		if(patt.test(PERMISSION)==false && patt2.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{

		if(is_m_vendor_form_valid()){
			var vendor_id_field_pk=null;
			var vendor_kode_field=null;
			var vendor_name_field=null;
			var vendor_type_field=null;
			var vendor_address_field=null;
			var vendor_phone_field=null;
			var vendor_fax_field=null;
			var vendor_email_field=null;
			var vendor_cp_field=null;
			var vendor_dir_field=null;
			var vendor_dirpos_field=null;
			var vendor_rek_field=null;
			var vendor_bank_field=null;
			var vendor_bankowner_field=null;
			var vendor_cert_field=null;
			var vendor_npwp_field=null;
			var vendor_certdate_field_date="";
			var vendor_active_field=null;
			/* var vendor_created_date_field_date="";
			var vendor_created_by_field=null;
			var vendor_updated_date_field_date="";
			var vendor_updated_by_field=null;
			var vendor_updated_count_field=null; */
			var m_div_id_field=null;

			vendor_id_field_pk=get_pk_id();
			if(vendor_kodeField.getValue()!== null){vendor_kode_field = vendor_kodeField.getValue();}
			if(vendor_nameField.getValue()!== null){vendor_name_field = vendor_nameField.getValue();}
			// if(vendor_typeField.getValue()!== null){vendor_type_field = vendor_typeField.getValue();}
			if(vendor_addressField.getValue()!== null){vendor_address_field = vendor_addressField.getValue();}
			if(vendor_phoneField.getValue()!== null){vendor_phone_field = vendor_phoneField.getValue();}
			if(vendor_faxField.getValue()!== null){vendor_fax_field = vendor_faxField.getValue();}
			if(vendor_emailField.getValue()!== null){vendor_email_field = vendor_emailField.getValue();}
			if(vendor_cpField.getValue()!== null){vendor_cp_field = vendor_cpField.getValue();}
			if(vendor_dirField.getValue()!== null){vendor_dir_field = vendor_dirField.getValue();}
			if(vendor_dirposField.getValue()!== null){vendor_dirpos_field = vendor_dirposField.getValue();}
			if(vendor_rekField.getValue()!== null){vendor_rek_field = vendor_rekField.getValue();}
			if(vendor_bankField.getValue()!== null){vendor_bank_field = vendor_bankField.getValue();}
			if(vendor_bankownerField.getValue()!== null){vendor_bankowner_field = vendor_bankownerField.getValue();}
			if(vendor_certField.getValue()!== null){vendor_cert_field = vendor_certField.getValue();}
			if(vendor_npwpField.getValue()!== null){vendor_npwp_field = vendor_npwpField.getValue();}
			if(vendor_certdateField.getValue()!== ""){vendor_certdate_field_date = vendor_certdateField.getValue().format('Y-m-d');}
			if(vendor_activeField.getValue()!== null){vendor_active_field = vendor_activeField.getValue();}
			/* if(vendor_created_dateField.getValue()!== ""){vendor_created_date_field_date = vendor_created_dateField.getValue().format('Y-m-d');}
			if(vendor_created_byField.getValue()!== null){vendor_created_by_field = vendor_created_byField.getValue();}
			if(vendor_updated_dateField.getValue()!== ""){vendor_updated_date_field_date = vendor_updated_dateField.getValue().format('Y-m-d');}
			if(vendor_updated_byField.getValue()!== null){vendor_updated_by_field = vendor_updated_byField.getValue();}
			if(vendor_updated_countField.getValue()!== null){vendor_updated_count_field = vendor_updated_countField.getValue();}
			if(m_div_idField.getValue()!== null){m_div_id_field = m_div_idField.getValue();}
			if(m_div_id_field == 1){
				vendor_type_field = "S";
			}else{
				vendor_type_field = "K";
			} */
			if(vendor_activeField.getValue()!== null){vendor_active_field = vendor_activeField.items.get(0).getGroupValue();}
			if(m_div_idField.getValue()!== null){m_div_id_field = m_div_idField.getValue();}
			
			Ext.Ajax.request({
				waitMsg: 'Please wait...',
				url: 'index.php?c=c_m_vendor&m=get_action',
				params: {
					vendor_id	: vendor_id_field_pk,
					vendor_kode	: vendor_kode_field,
					vendor_name	: vendor_name_field,
					vendor_type	: vendor_type_field,
					vendor_address	: vendor_address_field,
					vendor_phone	: vendor_phone_field,
					vendor_fax	: vendor_fax_field,
					vendor_email	: vendor_email_field,
					vendor_cp	: vendor_cp_field,
					vendor_dir	: vendor_dir_field,
					vendor_dirpos	: vendor_dirpos_field,
					vendor_rek	: vendor_rek_field,
					vendor_bank	: vendor_bank_field,
					vendor_bankowner	: vendor_bankowner_field,
					vendor_cert	: vendor_cert_field,
					vendor_npwp	: vendor_npwp_field,
					vendor_certdate	: vendor_certdate_field_date,
					vendor_active	: vendor_active_field,
					/* vendor_created_date	: vendor_created_date_field_date,
					vendor_created_by	: vendor_created_by_field,
					vendor_updated_date	: vendor_updated_date_field_date,
					vendor_updated_by	: vendor_updated_by_field,
					vendor_updated_count	: vendor_updated_count_field, */
					m_div_id	: m_div_id_field,
					task: post2db
				},
				success: function(response){
					var result=eval(response.responseText);
					switch(result){
						case 1:
							Ext.MessageBox.alert(post2db+' OK',SUCCESS_SAVE);
							post2db = "CREATE";
							m_vendor_DataStore.reload();
							m_vendor_reset_form();
							break;
						default:
							Ext.MessageBox.show({
							   title: 'Warning',
							   msg: FAILED_SAVE,
							   buttons: Ext.MessageBox.OK,
							   animEl: 'save',
							   icon: Ext.MessageBox.WARNING
							});
							break;
					}
				},
				failure: function(response){
					Ext.MessageBox.show({
						   title: 'Error',
						   msg: FAILED_CONNECTION,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'database',
						   icon: Ext.MessageBox.ERROR
					});
				}
			});

		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_VALID_FORM,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}

		}
	}
 	/* End of Function */

  	/* Function for get PK field */
	function get_pk_id(){
		if(post2db=='UPDATE')
			return m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_id');
		return 0;
	}
	/* End of Function  */

	/* Reset form before loading */
	function m_vendor_reset_form(){
		/* vendor_idField.reset();
		vendor_idField.setValue(null); */
		vendor_kodeField.reset();
		vendor_kodeField.setValue(null);
		vendor_nameField.reset();
		vendor_nameField.setValue(null);
		vendor_typeField.reset();
		vendor_typeField.setValue(null);
		vendor_addressField.reset();
		vendor_addressField.setValue(null);
		vendor_phoneField.reset();
		vendor_phoneField.setValue(null);
		vendor_faxField.reset();
		vendor_faxField.setValue(null);
		vendor_emailField.reset();
		vendor_emailField.setValue(null);
		vendor_cpField.reset();
		vendor_cpField.setValue(null);
		vendor_dirField.reset();
		vendor_dirField.setValue(null);
		vendor_dirposField.reset();
		vendor_dirposField.setValue(null);
		vendor_rekField.reset();
		vendor_rekField.setValue(null);
		vendor_bankField.reset();
		vendor_bankField.setValue(null);
		vendor_bankownerField.reset();
		vendor_bankownerField.setValue(null);
		vendor_certField.reset();
		vendor_certField.setValue(null);
		vendor_npwpField.reset();
		vendor_npwpField.setValue(null);
		vendor_certdateField.reset();
		vendor_certdateField.setValue(null);
		vendor_activeField.reset();
		vendor_activeField.setValue('vendor_aktif', true);
		/* vendor_created_dateField.reset();
		vendor_created_dateField.setValue(null);
		vendor_created_byField.reset();
		vendor_created_byField.setValue(null);
		vendor_updated_dateField.reset();
		vendor_updated_dateField.setValue(null);
		vendor_updated_byField.reset();
		vendor_updated_byField.setValue(null);
		vendor_updated_countField.reset();
		vendor_updated_countField.setValue(null); */
		m_div_idField.reset();
		m_div_idField.setValue(null);
		
		/* if(m_vendor_saveForm.collapsed == false){
			m_vendor_saveForm.toggleCollapse(true);
		} */
	}
 	/* End of Function */

	/* setValue to EDIT */
	function m_vendor_set_form(){
		// vendor_idField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_id'));
		vendor_kodeField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_kode'));
		vendor_nameField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_name'));
		vendor_typeField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_type'));
		vendor_addressField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_address'));
		vendor_phoneField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_phone'));
		vendor_faxField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_fax'));
		vendor_emailField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_email'));
		vendor_cpField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_cp'));
		vendor_dirField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_dir'));
		vendor_dirposField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_dirpos'));
		vendor_rekField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_rek'));
		vendor_bankField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_bank'));
		vendor_bankownerField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_bankowner'));
		vendor_certField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_cert'));
		vendor_npwpField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_npwp'));
		m_div_idField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('m_div_id'));
		console.log(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('m_div_id'));
	//	vendor_certdateField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_certdate'));
		
		if (m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_certdate') != null &&
		m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_certdate').format('d-m-Y') != '30-11-00-1' ){
		vendor_certdateField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_certdate'));}
		
		m_div_idField.setValue(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('m_div_id'));
		 if(m_vendor_ListEditorGrid.getSelectionModel().getSelected().get('vendor_active') == 'Y'){
			vendor_activeField.setValue('vendor_aktif', true);
		 }else{
			vendor_activeField.setValue('vendor_unaktif', true);
		 }
	}
	/* End setValue to EDIT*/

	/* Function for Check if the form is valid */
	function is_m_vendor_form_valid(){
		return (vendor_kodeField.isValid() && vendor_nameField.isValid() && m_div_idField.isValid() && vendor_dirField.isValid() && vendor_dirposField.isValid());
	}
  	/* End of Function */

  	/* Function for Displaying  create Window Form */
	function display_form_window(){
			post2db='CREATE';
			msg='created';
			/* if(m_vendor_saveForm.collapsed == true){
				m_vendor_saveForm.toggleCollapse(true);
			} */
			m_vendor_reset_form();
	}
  	/* End of Function */

  	/* Function for Delete Confirm */
	function m_vendor_confirm_delete(){
		// only one m_vendor is selected here
		if(m_vendor_ListEditorGrid.selModel.getCount() == 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_DELETE, m_vendor_delete);
		} else if(m_vendor_ListEditorGrid.selModel.getCount() > 1){
			Ext.MessageBox.confirm('Confirmation',CONFIRM_MULTI_DELETE, m_vendor_delete);
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_DELETE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
  	/* End of Function */

	/* Function for Update Confirm */
	function m_vendor_confirm_update(){
		/* only one record is selected here */
		if(m_vendor_ListEditorGrid.selModel.getCount() == 1) {
			post2db='UPDATE';
			msg='updated';
			/* if(m_vendor_saveForm.collapsed == true){
				m_vendor_saveForm.toggleCollapse(true);
			} */
			m_vendor_set_form();
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_UPDATE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
  	/* End of Function */

  	/* Function for Delete Record */
	function m_vendor_delete(btn){
		if(btn=='yes'){

		var patt=new RegExp("D");
		if(patt.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{

			var selections = m_vendor_ListEditorGrid.selModel.getSelections();
			var prez = [];
			for(var i = 0; i< m_vendor_ListEditorGrid.selModel.getCount(); i++){
				prez.push(selections[i].json.vendor_id);
			}
			var encoded_array = Ext.encode(prez);
			Ext.Ajax.request({
				waitMsg: 'Please Wait',
				url: 'index.php?c=c_m_vendor&m=get_action',
				params: { task: "DELETE", ids:  encoded_array },
				success: function(response){
					var result=eval(response.responseText);
					switch(result){
						case 1:
							m_vendor_DataStore.reload();
							break;
						default:
							Ext.MessageBox.show({
								title: 'Warning',
								msg: FAILED_DELETE,
								buttons: Ext.MessageBox.OK,
								animEl: 'save',
								icon: Ext.MessageBox.WARNING
							});
							break;
					}
				},
				failure: function(response){
					Ext.MessageBox.show({
					   title: 'Error',
					   msg: FAILED_CONNECTION,
					   buttons: Ext.MessageBox.OK,
					   animEl: 'database',
					   icon: Ext.MessageBox.ERROR
					});
				}
			});

			}

		}
	}
  	/* End of Function */

	/* Function for Retrieve DataStore */
	m_vendor_DataStore = new Ext.data.Store({
		id: 'm_vendor_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_m_vendor&m=get_action',
			method: 'POST'
		}),
		baseParams:{task: "LIST", start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'vendor_id'
		},[
			{name: 'vendor_id', type: 'int', mapping: 'vendor_id'},
			{name: 'vendor_kode', type: 'string', mapping: 'vendor_kode'},
			{name: 'vendor_name', type: 'string', mapping: 'vendor_name'},
			{name: 'vendor_type', type: 'string', mapping: 'vendor_type'},
			{name: 'vendor_address', type: 'string', mapping: 'vendor_address'},
			{name: 'vendor_phone', type: 'string', mapping: 'vendor_phone'},
			{name: 'vendor_fax', type: 'string', mapping: 'vendor_fax'},
			{name: 'vendor_email', type: 'string', mapping: 'vendor_email'},
			{name: 'vendor_cp', type: 'string', mapping: 'vendor_cp'},
			{name: 'vendor_dir', type: 'string', mapping: 'vendor_dir'},
			{name: 'vendor_dirpos', type: 'string', mapping: 'vendor_dirpos'},
			{name: 'vendor_rek', type: 'string', mapping: 'vendor_rek'},
			{name: 'vendor_bank', type: 'string', mapping: 'vendor_bank'},
			{name: 'vendor_bankowner', type: 'string', mapping: 'vendor_bankowner'},
			{name: 'vendor_cert', type: 'string', mapping: 'vendor_cert'},
			{name: 'vendor_npwp', type: 'string', mapping: 'vendor_npwp'},
			{name: 'vendor_certdate', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'vendor_certdate'},
			{name: 'vendor_certdate_str', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'vendor_certdate_str'},
			{name: 'vendor_active', type: 'string', mapping: 'vendor_active'},
			{name: 'vendor_created_date', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'vendor_created_date'},
			{name: 'vendor_created_by', type: 'string', mapping: 'vendor_created_by'},
			{name: 'vendor_updated_date', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'vendor_updated_date'},
			{name: 'vendor_updated_by', type: 'string', mapping: 'vendor_updated_by'},
			{name: 'vendor_updated_count', type: 'int', mapping: 'vendor_updated_count'},
			{name: 'm_div_id', type: 'varchar', mapping: 'm_div_id'},
			{name: 'div_name', type: 'varchar', mapping: 'div_name'}
		]),
		sortInfo:{field: 'vendor_id', direction: "DESC"}
	});
	
	var expander_vendor_list = new Ext.ux.grid.RowExpander({
        tpl : new Ext.Template(
                '<table width="95%">',
                '<tr>',
                '<td width="45%">',
                '<p><b>Kode Vendor :</b> {vendor_kode}<br><b>Nama Vendor :</b> {vendor_name}<br>',
                '<b>Alamat Vendor :</b> {vendor_address}<br><b>No.Telp :</b> {vendor_phone}<br>',
                '<b>No.Fax :</b> {vendor_fax}<br>',
                '<b>Nama Direktur :</b> {vendor_dir}<br><b>Jabatan :</b> {vendor_dirpos}<br><b>Contact Person :</b> {vendor_cp}</p>',
                '</td>',
                '<td width="45%">',
                '<p><b>Email :</b> {vendor_email}<br><b>Rekening :</b> {vendor_rek}<br><b>Bank :</b> {vendor_bank}<br>',
                '<b>Pemilik Rekening :</b> {vendor_bankowner}<br><b>Sertifikasi :</b> {vendor_cert}',
                '<br><b>Tgl Sertifikasi :</b> {vendor_certdate_str:date("l, F d, Y")}<br>',
                '<b>NPWP :</b> {vendor_npwp}<br><b>Kategori Vendor :</b> {div_name}</p>',
                '</td>',
                '</tr>',
                '</table>'
            )
  	});
	/* End of Function */

  	/* Function for Identify of Window Column Model */
	m_vendor_ColumnModel = new Ext.grid.ColumnModel(
		[expander_vendor_list,
		{
			header: 'Vendor Id',
			dataIndex: 'vendor_id',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Kode Vendor',
			dataIndex: 'vendor_kode',
			width: 150,
			sortable: true
		},{
			header: 'Nama Vendor',
			dataIndex: 'vendor_name',
			width: 150,
			sortable: true
		},
		{
			header: 'Type',
			dataIndex: 'vendor_type',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Alamat',
			dataIndex: 'vendor_address',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'No. Telepon',
			dataIndex: 'vendor_phone',
			width: 150,
			sortable: true
		},
		{
			header: 'No. Fax',
			dataIndex: 'vendor_fax',
			width: 150,
			sortable: true
		},
		{
			header: 'Email',
			dataIndex: 'vendor_email',
			width: 150,
			sortable: true
		},
		{
			header: 'CP',
			dataIndex: 'vendor_cp',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Direktur',
			dataIndex: 'vendor_dir',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Jabatan',
			dataIndex: 'vendor_dirpos',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Rekening',
			dataIndex: 'vendor_rek',
			width: 150,
			sortable: true
		},
		{
			header: 'Bank',
			dataIndex: 'vendor_bank',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Pemilik Rekening',
			dataIndex: 'vendor_bankowner',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Sertifikasi',
			dataIndex: 'vendor_cert',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Tgl Sertifikasi',
			dataIndex: 'vendor_certdate',
			width: 150,
			sortable: true,
			hidden : true
		},{
			header: 'NPWP',
			dataIndex: 'vendor_npwp',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Vendor Created Date',
			dataIndex: 'vendor_created_date',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Vendor Created By',
			dataIndex: 'vendor_created_by',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Vendor Updated Date',
			dataIndex: 'vendor_updated_date',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Vendor Updated By',
			dataIndex: 'vendor_updated_by',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Vendor Updated Count',
			dataIndex: 'vendor_updated_count',
			width: 150,
			sortable: true,
			hidden : true
		},
		{
			header: 'Kategori',
			dataIndex: 'div_name',
			width: 150,
			sortable: true
		},
		{
			header: 'Job',
			dataIndex: 'm_div_id',
			width: 150,
			sortable: true,
			hidden : true
		},{
			header: 'Aktif',
			dataIndex: 'vendor_active',
			width: 150,
			sortable: true
		}
		]);

	m_vendor_ColumnModel.defaultSortable= true;
	/* End of Function */

    /* Button Control */
    m_vendor_gbtn_add=new Ext.Button({
	    text: BTN_ADD_TITLE,
		tooltip: BTN_ADD_TOOLTIP,
		iconCls:'icon-adds',
		handler: display_form_window
    });

    m_vendor_gbtn_update=new Ext.Button({
	    text: BTN_EDIT_TITLE,
		tooltip: BTN_EDIT_TOOLTIP,
		iconCls:'icon-update',
		handler: m_vendor_confirm_update
	});

    m_vendor_gbtn_delete=new Ext.Button({
	    text: BTN_DELETE_TITLE,
		tooltip: BTN_DELETE_TOOLTIP,
		iconCls:'icon-delete',
		handler: m_vendor_confirm_delete
	});

    /*Context Menu Button */

	m_vendor_cbtn_update=new Ext.menu.Item({
		text: BTN_EDIT_TITLE,
		tooltip: BTN_EDIT_TOOLTIP,
		iconCls:'icon-update',
		handler: m_vendor_editContextMenu
	});

	m_vendor_cbtn_delete=new Ext.menu.Item({
		text: BTN_DELETE_TITLE,
		tooltip: BTN_DELETE_TOOLTIP,
		iconCls:'icon-delete',
		handler: m_vendor_confirm_delete
	});
	
	/* Declare DataStore and  show datagrid list */
	m_vendor_ListEditorGrid =  new Ext.grid.EditorGridPanel({
		id: 'm_vendor_ListEditorGrid',
		el: 'fp_m_vendor',
		title: TITLE_LIST,
		autoHeight: true,
		collapsible: true,
		store: m_vendor_DataStore, // DataStore
		cm: m_vendor_ColumnModel, // Nama-nama Columns
		enableColLock:false,
		frame: true,
		clicksToEdit:2, // 2xClick untuk bisa meng-Edit inLine Data
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:true },
		plugins : expander_vendor_list,
	  	width: 900,
		bbar: new Ext.PagingToolbar({
			pageSize: pageS,
			store: m_vendor_DataStore,
			displayInfo: true
		}),
		/* Add Control on ToolBar */
		tbar: [
		m_vendor_gbtn_add, '-',
		m_vendor_gbtn_update, '-',
		m_vendor_gbtn_delete, '-',
		new Ext.app.SearchField({
			store: m_vendor_DataStore,
			listeners:{
				specialkey: function(f,e){
					if(e.getKey() == e.ENTER){
						m_vendor_DataStore.baseParams={task:'LIST', start:0, limit:pageS};
		            }
				},
				render: function(c){
				Ext.get(this.id).set({qtitle: BTN_SIMPLE_SEARCH_TOOLTIP});
				}
			},
			width: 120
		}),'-',{
			text: BTN_REFRESH_TITLE,
			tooltip: BTN_REFERSH_TOOLTIP,
			handler: m_vendor_reset_search,
			iconCls:'icon-refresh'
		},'-',{
			text: BTN_EXCEL_TITLE,
			tooltip: BTN_EXCEL_TOOLTIP,
			iconCls:'icon-xls',
			handler: m_vendor_export_excel
		}, '-',{
			text: BTN_PRINT_TITLE,
			tooltip: BTN_PRINT_TOOLTIP,
			iconCls:'icon-print',
			handler: m_vendor_print
		}
		]
	});
	m_vendor_ListEditorGrid.render();
	/* End of DataStore */

	/* Create Context Menu */
	m_vendor_ContextMenu = new Ext.menu.Menu({
		id: 'm_vendor_ContextMenu',
		items: [
		m_vendor_cbtn_update,
		m_vendor_cbtn_delete,
		'-',
		{
			text: BTN_PRINT_TITLE,
			tooltip: BTN_PRINT_TOOLTIP,
			iconCls:'icon-print',
			handler: m_vendor_print
		},
		{
			text: BTN_EXCEL_TITLE,
			tooltip: BTN_EXCEL_TOOLTIP,
			iconCls:'icon-xls',
			handler: m_vendor_export_excel
		}
		]
	});
	/* End of Declaration */

	/* Event while selected row via context menu */
	function onm_vendor_ContextMenu(grid, rowIndex, e) {
		e.stopEvent();
		var coords = e.getXY();
		m_vendor_ContextMenu.rowRecord = grid.store.getAt(rowIndex);
		grid.selModel.selectRow(rowIndex);
		m_vendor_SelectedRow=rowIndex;
		m_vendor_ContextMenu.showAt([coords[0], coords[1]]);
  	}
  	/* End of Function */

	/* function for editing row via context menu */
	function m_vendor_editContextMenu(){
		//m_vendor_ListEditorGrid.startEditing(m_vendor_SelectedRow,1);
		m_vendor_confirm_update();
  	}
	/* End of Function */
	
	/* Data Store For Combo Box */
	
	m_div_DataStore = new Ext.data.Store({
		id: 'm_div_DataStore',
		autoLoad : true,
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_m_vendor&m=get_div', 
			method: 'POST'
		}),
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'div_id'
		},[
			{name: 'div_id', type: 'int', mapping: 'div_id'}, 
			{name: 'div_name', type: 'string', mapping: 'div_name'}
		]),
		sortInfo:{field: 'div_id', direction: "ASC"}
	});

	/* End Data Store For Combo Box */
	

	m_vendor_ListEditorGrid.addListener('rowcontextmenu', onm_vendor_ContextMenu);
	m_vendor_DataStore.load({params: {start: 0, limit: pageS}});	// load DataStore
	m_vendor_ListEditorGrid.on('afteredit', m_vendor_inline_update); // inLine Editing Record

	vendor_idField= new Ext.form.NumberField({
		id: 'vendor_idField',
		fieldLabel: 'Id ',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	vendor_kodeField= new Ext.form.TextField({
		id: 'vendor_kodeField',
		fieldLabel: 'Kode Vendor ',
		maxLength: 200,
		anchor: '95%',
		allowBlank : false
	});
	vendor_nameField= new Ext.form.TextField({
		id: 'vendor_nameField',
		fieldLabel: 'Nama Vendor ',
		maxLength: 200,
		anchor: '95%',
		allowBlank : false
	});
	vendor_typeField= new Ext.form.TextField({
		id: 'vendor_typeField',
		fieldLabel: 'Type ',
		maxLength: 1,
		hidden : true,
		anchor: '95%'
	});
	vendor_addressField= new Ext.form.TextField({
		id: 'vendor_addressField',
		fieldLabel: 'Alamat ',
		maxLength: 300,
		anchor: '95%'
	});
	vendor_phoneField= new Ext.form.TextField({
		id: 'vendor_phoneField',
		fieldLabel: 'No. Telepon ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_faxField= new Ext.form.TextField({
		id: 'vendor_faxField',
		fieldLabel: 'No. Fax ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_emailField= new Ext.form.TextField({
		id: 'vendor_emailField',
		fieldLabel: 'Email ',
		maxLength: 100,
		anchor: '95%'
	});
	vendor_cpField= new Ext.form.TextField({
		id: 'vendor_cpField',
		fieldLabel: 'Contact Person ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_dirField= new Ext.form.TextField({
		id: 'vendor_dirField',
		fieldLabel: 'Nama Direktur ',
		maxLength: 45,
		anchor: '95%',
		allowBlank : false
	});
	vendor_dirposField= new Ext.form.TextField({
		id: 'vendor_dirposField',
		fieldLabel: 'Jabatan',
		maxLength: 45,
		anchor: '95%',
		allowBlank : false
	});
	vendor_rekField= new Ext.form.TextField({
		id: 'vendor_rekField',
		fieldLabel: 'Rekening ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_bankField= new Ext.form.TextField({
		id: 'vendor_bankField',
		fieldLabel: 'Bank ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_bankownerField= new Ext.form.TextField({
		id: 'vendor_bankownerField',
		fieldLabel: 'Pemilik Rekening ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_certField= new Ext.form.TextField({
		id: 'vendor_certField',
		fieldLabel: 'Sertifikasi ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_certdateField= new Ext.form.DateField({
		id: 'vendor_certdateField',
		fieldLabel: 'Tgl Sertifikasi ',
		format : 'Y-m-d'
	});
	vendor_activeField = new Ext.form.RadioGroup({
		fieldLabel: "Aktif",
		id: "vendor_activeField",
		width : 150,
		defaults : {xtype : 'radio', name : 'vendor_activeField'},
        items: [
            {
                boxLabel: "Ya",
                inputValue: "Y",
				checked : true,
				id : 'vendor_aktif'
            },
            {
                boxLabel: "Tidak",
                inputValue: "T",
				id : 'vendor_unaktif'
            }
        ]
	});
	vendor_created_dateField= new Ext.form.DateField({
		id: 'vendor_created_dateField',
		fieldLabel: 'Vendor Created Date ',
		format : 'Y-m-d',
		anchor: '95%'
	});
	vendor_created_byField= new Ext.form.TextField({
		id: 'vendor_created_byField',
		fieldLabel: 'Vendor Created By ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_updated_dateField= new Ext.form.DateField({
		id: 'vendor_updated_dateField',
		fieldLabel: 'Vendor Updated Date ',
		format : 'Y-m-d',
		anchor: '95%'
	});
	vendor_updated_byField= new Ext.form.TextField({
		id: 'vendor_updated_byField',
		fieldLabel: 'Vendor Updated By ',
		maxLength: 45,
		anchor: '95%'
	});
	vendor_updated_countField= new Ext.form.NumberField({
		id: 'vendor_updated_countField',
		fieldLabel: 'Vendor Updated Count ',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	});
	
	/* m_div_idField= new Ext.form.NumberField({
		id: 'm_div_idField',
		fieldLabel: 'Job ',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		maskRe: /([0-9]+)$/
	}); */
	vendor_npwpField= new Ext.form.TextField({
		id: 'vendor_npwpField',
		fieldLabel: 'NPWP ',
		maxLength: 45,
		anchor: '95%'
	});
	
	m_div_idField = new Ext.ux.form.SuperBoxSelect({

	// m_div_idField= new Ext.form.ComboBox({
		id: 'm_div_idField',
		name: 'div_name',
		fieldLabel: 'Kategori Vendor',
		store: m_div_DataStore,
		mode: 'remote',
		displayField:'div_name',
		valueField: 'div_id',
        editable: true,
        allowBlank: false,
		anchor: '95%',
		pageSize: 15,
		triggerAction: 'all',
		forceSelection:true,
		allowBlank : false
	});


	m_vendor_btn_Save=new Ext.Button({
		text: BTN_SAVE,
		handler: m_vendor_save
	});
	/* Function for retrieve create Window Panel*/
	m_vendor_saveForm = new Ext.FormPanel({
		labelAlign: 'left',
		title: TITLE_FORM+' Vendor',
		bodyStyle:'padding:5px',
		autoHeight:true,
		layout:'column',
		width: 700,
		collapsible: true,
		frame: true,
		renderTo: 'elwindow_m_vendor_save',
		items:[{
			columnWidth:0.5,
			layout: 'form',
			border:false,
			items:[vendor_kodeField ,vendor_nameField ,vendor_typeField ,vendor_addressField ,vendor_phoneField ,vendor_faxField
			       ,vendor_emailField ,vendor_cpField ,vendor_dirField,vendor_dirposField
			       ,new  Ext.form.Label({html:'Keterangan : <font color=red>*</font>  '+INFO_REQUIRED })]
		},
		{
			columnWidth:0.5,
			layout: 'form',
			border:false,
			items:[vendor_rekField ,vendor_bankField ,vendor_bankownerField ,vendor_certField ,vendor_certdateField,vendor_npwpField
			       ,m_div_idField ,vendor_activeField]
		} ],
		buttons: [m_vendor_btn_Save
			,{
				text: BTN_CANCEL,
				handler: function(){
					m_vendor_reset_form();
				}
			}
		]
	});
	/* End  of Function*/



	/* Function for reset search result */
	function m_vendor_reset_search(){
		m_vendor_DataStore.baseParams = { task: 'LIST' };
		m_vendor_DataStore.reload({params: {start: 0, limit: pageS}});
	};
	/* End of Fuction */

	/* Function for print List Grid */
	function m_vendor_print(){
		var searchquery = "";
		var vendor_id_print=null;
		var vendor_name_print=null;
		var vendor_type_print=null;
		var vendor_address_print=null;
		var vendor_phone_print=null;
		var vendor_fax_print=null;
		var vendor_email_print=null;
		var vendor_cp_print=null;
		var vendor_dir_print=null;
		var vendor_dirpos_print=null;
		var vendor_rek_print=null;
		var vendor_bank_print=null;
		var vendor_bankowner_print=null;
		var vendor_cert_print=null;
		var vendor_certdate_print_date="";
		var vendor_active_print=null;
		/* var vendor_created_date_print_date="";
		var vendor_created_by_print=null;
		var vendor_updated_date_print_date="";
		var vendor_updated_by_print=null;
		var vendor_updated_count_print=null; */
		var m_div_id_print=null;

		if(m_vendor_DataStore.baseParams.query!==null){searchquery = m_vendor_DataStore.baseParams.query;}
		if(m_vendor_DataStore.baseParams.vendor_id!==null){vendor_id_print = m_vendor_DataStore.baseParams.vendor_id;}
		if(m_vendor_DataStore.baseParams.vendor_name!==null){vendor_name_print = m_vendor_DataStore.baseParams.vendor_name;}
		if(m_vendor_DataStore.baseParams.vendor_type!==null){vendor_type_print = m_vendor_DataStore.baseParams.vendor_type;}
		if(m_vendor_DataStore.baseParams.vendor_address!==null){vendor_address_print = m_vendor_DataStore.baseParams.vendor_address;}
		if(m_vendor_DataStore.baseParams.vendor_phone!==null){vendor_phone_print = m_vendor_DataStore.baseParams.vendor_phone;}
		if(m_vendor_DataStore.baseParams.vendor_fax!==null){vendor_fax_print = m_vendor_DataStore.baseParams.vendor_fax;}
		if(m_vendor_DataStore.baseParams.vendor_email!==null){vendor_email_print = m_vendor_DataStore.baseParams.vendor_email;}
		if(m_vendor_DataStore.baseParams.vendor_cp!==null){vendor_cp_print = m_vendor_DataStore.baseParams.vendor_cp;}
		if(m_vendor_DataStore.baseParams.vendor_dir!==null){vendor_dir_print = m_vendor_DataStore.baseParams.vendor_dir;}
		if(m_vendor_DataStore.baseParams.vendor_dirpos!==null){vendor_dirpos_print = m_vendor_DataStore.baseParams.vendor_dirpos;}
		if(m_vendor_DataStore.baseParams.vendor_rek!==null){vendor_rek_print = m_vendor_DataStore.baseParams.vendor_rek;}
		if(m_vendor_DataStore.baseParams.vendor_bank!==null){vendor_bank_print = m_vendor_DataStore.baseParams.vendor_bank;}
		if(m_vendor_DataStore.baseParams.vendor_bankowner!==null){vendor_bankowner_print = m_vendor_DataStore.baseParams.vendor_bankowner;}
		if(m_vendor_DataStore.baseParams.vendor_cert!==null){vendor_cert_print = m_vendor_DataStore.baseParams.vendor_cert;}
		if(m_vendor_DataStore.baseParams.vendor_certdate!==""){vendor_certdate_print_date = m_vendor_DataStore.baseParams.vendor_certdate;}
		if(m_vendor_DataStore.baseParams.vendor_active!==null){vendor_active_print = m_vendor_DataStore.baseParams.vendor_active;}
		/* if(m_vendor_DataStore.baseParams.vendor_created_date!==""){vendor_created_date_print_date = m_vendor_DataStore.baseParams.vendor_created_date;}
		if(m_vendor_DataStore.baseParams.vendor_created_by!==null){vendor_created_by_print = m_vendor_DataStore.baseParams.vendor_created_by;}
		if(m_vendor_DataStore.baseParams.vendor_updated_date!==""){vendor_updated_date_print_date = m_vendor_DataStore.baseParams.vendor_updated_date;}
		if(m_vendor_DataStore.baseParams.vendor_updated_by!==null){vendor_updated_by_print = m_vendor_DataStore.baseParams.vendor_updated_by;}
		if(m_vendor_DataStore.baseParams.vendor_updated_count!==null){vendor_updated_count_print = m_vendor_DataStore.baseParams.vendor_updated_count;}
		 */if(m_vendor_DataStore.baseParams.m_div_id!==null){m_div_id_print = m_vendor_DataStore.baseParams.m_div_id;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_m_vendor&m=get_action',
		params: {
			task: "PRINT",
		  	query: searchquery,
			vendor_id : vendor_id_print,
			vendor_name : vendor_name_print,
			vendor_type : vendor_type_print,
			vendor_address : vendor_address_print,
			vendor_phone : vendor_phone_print,
			vendor_fax : vendor_fax_print,
			vendor_email : vendor_email_print,
			vendor_cp : vendor_cp_print,
			vendor_dir : vendor_dir_print,
			vendor_dirpos : vendor_dirpos_print,
			vendor_rek : vendor_rek_print,
			vendor_bank : vendor_bank_print,
			vendor_bankowner : vendor_bankowner_print,
			vendor_cert : vendor_cert_print,
		  	vendor_certdate : vendor_certdate_print_date,
			vendor_active : vendor_active_print,
		  	/* vendor_created_date : vendor_created_date_print_date,
			vendor_created_by : vendor_created_by_print,
		  	vendor_updated_date : vendor_updated_date_print_date,
			vendor_updated_by : vendor_updated_by_print,
			vendor_updated_count : vendor_updated_count_print,
			 */m_div_id : m_div_id_print,
		  	currentlisting: m_vendor_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
				window.open('./print/m_vendor_printlist.html','m_vendorlist','height=600,width=800,resizable=1,scrollbars=0, menubar=0');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_PRINT,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	/* Enf Function */

	/* Function for print Export to Excel Grid */
	function m_vendor_export_excel(){
		var searchquery = "";
		var vendor_id_2excel=null;
		var vendor_name_2excel=null;
		var vendor_type_2excel=null;
		var vendor_address_2excel=null;
		var vendor_phone_2excel=null;
		var vendor_fax_2excel=null;
		var vendor_email_2excel=null;
		var vendor_cp_2excel=null;
		var vendor_dir_2excel=null;
		var vendor_dirpos_2excel=null;
		var vendor_rek_2excel=null;
		var vendor_bank_2excel=null;
		var vendor_bankowner_2excel=null;
		var vendor_cert_2excel=null;
		var vendor_certdate_2excel_date="";
		var vendor_active_2excel=null;
		/* var vendor_created_date_2excel_date="";
		var vendor_created_by_2excel=null;
		var vendor_updated_date_2excel_date="";
		var vendor_updated_by_2excel=null;
		var vendor_updated_count_2excel=null;
		 */var m_div_id_2excel=null;

		if(m_vendor_DataStore.baseParams.query!==null){searchquery = m_vendor_DataStore.baseParams.query;}
		if(m_vendor_DataStore.baseParams.vendor_id!==null){vendor_id_2excel = m_vendor_DataStore.baseParams.vendor_id;}
		if(m_vendor_DataStore.baseParams.vendor_name!==null){vendor_name_2excel = m_vendor_DataStore.baseParams.vendor_name;}
		if(m_vendor_DataStore.baseParams.vendor_type!==null){vendor_type_2excel = m_vendor_DataStore.baseParams.vendor_type;}
		if(m_vendor_DataStore.baseParams.vendor_address!==null){vendor_address_2excel = m_vendor_DataStore.baseParams.vendor_address;}
		if(m_vendor_DataStore.baseParams.vendor_phone!==null){vendor_phone_2excel = m_vendor_DataStore.baseParams.vendor_phone;}
		if(m_vendor_DataStore.baseParams.vendor_fax!==null){vendor_fax_2excel = m_vendor_DataStore.baseParams.vendor_fax;}
		if(m_vendor_DataStore.baseParams.vendor_email!==null){vendor_email_2excel = m_vendor_DataStore.baseParams.vendor_email;}
		if(m_vendor_DataStore.baseParams.vendor_cp!==null){vendor_cp_2excel = m_vendor_DataStore.baseParams.vendor_cp;}
		if(m_vendor_DataStore.baseParams.vendor_dir!==null){vendor_dir_2excel = m_vendor_DataStore.baseParams.vendor_dir;}
		if(m_vendor_DataStore.baseParams.vendor_dirpos!==null){vendor_dirpos_2excel = m_vendor_DataStore.baseParams.vendor_dirpos;}
		if(m_vendor_DataStore.baseParams.vendor_rek!==null){vendor_rek_2excel = m_vendor_DataStore.baseParams.vendor_rek;}
		if(m_vendor_DataStore.baseParams.vendor_bank!==null){vendor_bank_2excel = m_vendor_DataStore.baseParams.vendor_bank;}
		if(m_vendor_DataStore.baseParams.vendor_bankowner!==null){vendor_bankowner_2excel = m_vendor_DataStore.baseParams.vendor_bankowner;}
		if(m_vendor_DataStore.baseParams.vendor_cert!==null){vendor_cert_2excel = m_vendor_DataStore.baseParams.vendor_cert;}
		if(m_vendor_DataStore.baseParams.vendor_certdate!==""){vendor_certdate_2excel_date = m_vendor_DataStore.baseParams.vendor_certdate;}
		if(m_vendor_DataStore.baseParams.vendor_active!==null){vendor_active_2excel = m_vendor_DataStore.baseParams.vendor_active;}
		/* if(m_vendor_DataStore.baseParams.vendor_created_date!==""){vendor_created_date_2excel_date = m_vendor_DataStore.baseParams.vendor_created_date;}
		if(m_vendor_DataStore.baseParams.vendor_created_by!==null){vendor_created_by_2excel = m_vendor_DataStore.baseParams.vendor_created_by;}
		if(m_vendor_DataStore.baseParams.vendor_updated_date!==""){vendor_updated_date_2excel_date = m_vendor_DataStore.baseParams.vendor_updated_date;}
		if(m_vendor_DataStore.baseParams.vendor_updated_by!==null){vendor_updated_by_2excel = m_vendor_DataStore.baseParams.vendor_updated_by;}
		if(m_vendor_DataStore.baseParams.vendor_updated_count!==null){vendor_updated_count_2excel = m_vendor_DataStore.baseParams.vendor_updated_count;}
		 */if(m_vendor_DataStore.baseParams.m_div_id!==null){m_div_id_2excel = m_vendor_DataStore.baseParams.m_div_id;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_m_vendor&m=get_action',
		params: {
			task: "EXCEL",
		  	query: searchquery,
			vendor_id : vendor_id_2excel,
			vendor_name : vendor_name_2excel,
			vendor_type : vendor_type_2excel,
			vendor_address : vendor_address_2excel,
			vendor_phone : vendor_phone_2excel,
			vendor_fax : vendor_fax_2excel,
			vendor_email : vendor_email_2excel,
			vendor_cp : vendor_cp_2excel,
			vendor_dir : vendor_dir_2excel,
			vendor_dirpos : vendor_dirpos_2excel,
			vendor_rek : vendor_rek_2excel,
			vendor_bank : vendor_bank_2excel,
			vendor_bankowner : vendor_bankowner_2excel,
			vendor_cert : vendor_cert_2excel,
		  	vendor_certdate : vendor_certdate_2excel_date,
			vendor_active : vendor_active_2excel,
		  	/* vendor_created_date : vendor_created_date_2excel_date,
			vendor_created_by : vendor_created_by_2excel,
		  	vendor_updated_date : vendor_updated_date_2excel_date,
			vendor_updated_by : vendor_updated_by_2excel,
			vendor_updated_count : vendor_updated_count_2excel,
			 */m_div_id : m_div_id_2excel,
		  	currentlisting: m_vendor_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
		  		window.open('./print/m_vendor_printlist.xls');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_EXCEL,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	/*End of Function */

	/* Show Hide control for permission */
	var pattr=new RegExp("R");
	var pattc=new RegExp("C");
	var pattu=new RegExp("U");
	var pattd=new RegExp("D");

	if(pattc.test(PERMISSION)==false){
		m_vendor_gbtn_add.setVisible(false);
	}else{
		m_vendor_gbtn_add.setVisible(true);
	}

	if(pattu.test(PERMISSION)==false){
		m_vendor_gbtn_update.setVisible(false);
		m_vendor_cbtn_update.setVisible(false);
	}else{
		m_vendor_gbtn_update.setVisible(true);
		m_vendor_cbtn_update.setVisible(true);
	}

	if(pattd.test(PERMISSION)==false){
		m_vendor_gbtn_delete.setVisible(false);
		m_vendor_cbtn_delete.setVisible(false);
	}else{
		m_vendor_gbtn_delete.setVisible(true);
		m_vendor_cbtn_delete.setVisible(true);
	}

	if(pattc.test(PERMISSION)==false && pattu.test(PERMISSION)==false){
		m_vendor_btn_Save.setVisible(false);
	}else{
		m_vendor_btn_Save.setVisible(true);
	}
});
</script>
<body style: 'background: url(assets/images/desktop.jpg)'>
<div>
	<div class="col">
		<div id="elwindow_m_vendor_save"></div>
		<div>&nbsp;</div>
		<div id="fp_m_vendor"></div>
        <div id="elwindow_m_vendor_search"></div>
    </div>
</div>
</body>
</html>